package com.mszlu.news.admin.controller;

import com.mszlu.news.admin.model.params.CategoryParam;
import com.mszlu.news.admin.service.CategoryService;
import com.mszlu.news.admin.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "文章类型")
@RestController
@RequestMapping("category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @ApiOperation(value = "根据条件查询")
    @PostMapping("select")
    public Result selectCategory(@RequestBody CategoryParam categoryParam){
        return categoryService.selectCategory(categoryParam);
    }

    @ApiOperation(value = "新增类型")
    @PostMapping("insert")
    public Result insertCategory(@RequestBody CategoryParam categoryParam){
        return categoryService.insertCategory(categoryParam);
    }

    @ApiOperation(value = "更新类型")
    @PostMapping("update")
    public Result updateCategory(@RequestBody CategoryParam categoryParam){
        return categoryService.updateCategory(categoryParam);
    }

    @ApiOperation(value = "通过id删除类型")
    @PostMapping("delete/{id}")
    public Result deleteCategoryById(@PathVariable("id") Long categoryId){
        return categoryService.deleteCategoryById(categoryId);
    }
}
